function policy_effects = policy_effects_counter2(data_counterfactual,data_baseline,fp)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%;
%Compute Policy Effects (baseline vs. counterfactual) of Policy #2 (or Policy #3)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%;

%Pre-define matrices used to store results;

data_skills_movers_base    = NaN(1,fp.n_rip_sim);
data_skills_movers_counter = NaN(1,fp.n_rip_sim);

data_skills_receivers_base    = NaN(1,fp.n_rip_sim);
data_skills_receivers_counter = NaN(1,fp.n_rip_sim);

data_PS_movers_base    = NaN(1,fp.n_rip_sim);
data_PS_movers_counter = NaN(1,fp.n_rip_sim);

data_PS_receivers_base    = NaN(1,fp.n_rip_sim);
data_PS_receivers_counter = NaN(1,fp.n_rip_sim);

data_inv_movers_base      = NaN(1,fp.n_rip_sim);
data_inv_movers_counter   = NaN(1,fp.n_rip_sim);

data_inv_receivers_base    = NaN(1,fp.n_rip_sim);
data_inv_receivers_counter = NaN(1,fp.n_rip_sim);

for h = 1:1:fp.n_rip_sim %loop over various simulations;


    %%%%%%%%%%%%%%%%%%%%%%%%%%;
    %Movers;
    %%%%%%%%%%%%%%%%%%%%%%%%%%;

    %%%%%%%%%%%%%
    %Baseline;
    %%%%%%%%%%%%%

    data_baseline_origin = data_baseline{fp.origin_neigh};

    %a) Skills;
    skills_children_T = data_baseline_origin(  data_baseline_origin(:,fp.ind_data.child_age,h)==11 , fp.ind_data.child_C_tp1 , h ) ;
    data_skills_movers_base(1,h) =   nanmean(log(  skills_children_T(fp.id_moved_children(:,h)==1)  ) ) ;

    %b) Parenting Style;
    PS = data_baseline_origin(  data_baseline_origin(:,fp.ind_data.child_age,h)<11 , fp.ind_data.ParStyle , h ) ;
    kids_id = repmat( fp.id_moved_children(:,h) , [2 ,1 ] );
    data_PS_movers_base(1,h)     = nanmean( PS(kids_id==1)  );

    %c) Parental Investments;
    inv = data_baseline_origin(  : , fp.ind_data.inv , h ) ;
    kids_id = repmat( fp.id_moved_children(:,h) , [3 ,1 ] );
    data_inv_movers_base(1,h)     = nanmean( inv(kids_id==1)  );

    %%%%%%%%%%%%%%%%%%
    %Counterfactual (movers=1);
    %%%%%%%%%%%%%%%%%%

    %a) Skills;
    skills_children_T = data_counterfactual( data_counterfactual(:,fp.ind_data.child_age,h)==11 & data_counterfactual(:,fp.ind_data.moved,h)==1, fp.ind_data.child_C_tp1 , h ) ;
    data_skills_movers_counter(1,h) =  nanmean( log(  skills_children_T ) );

    %b) Parenting Style;
    PS = data_counterfactual( data_counterfactual(:,fp.ind_data.child_age,h)<11 & data_counterfactual(:,fp.ind_data.moved,h)==1, fp.ind_data.ParStyle , h ) ;
    data_PS_movers_counter(1,h) =  nanmean( PS );

    %c) Parental Investments;
    inv = data_counterfactual( data_counterfactual(:,fp.ind_data.moved,h)==1, fp.ind_data.inv , h ) ;
    data_inv_movers_counter(1,h) =  nanmean( inv );

    %%%%%%%%%%%%%%%%%%%%%%%%%%;
    %Receivers;
    %%%%%%%%%%%%%%%%%%%%%%%%%%;

    %%%%%%%%%%%%%%%%%%
    %Baseline;
    %%%%%%%%%%%%%%%%%%

    %a) Skills;
    data_baseline_receiving = data_baseline{fp.receiving_neigh};
    skills_children_T = data_baseline_receiving(  data_baseline_receiving(:,fp.ind_data.child_age,h)==11 , fp.ind_data.child_C_tp1 , h ) ;
    data_skills_receivers_base(1,h) = nanmean(log( skills_children_T ) ) ;

    %b) Parenting Style;
    PS = data_baseline_receiving(  data_baseline_receiving(:,fp.ind_data.child_age,h)<11 , fp.ind_data.ParStyle , h ) ;
    data_PS_receivers_base(1,h) = nanmean( PS ) ;

    %c) Parental Investments;
    inv = data_baseline_receiving(  : , fp.ind_data.inv , h ) ;
    data_inv_receivers_base(1,h) = nanmean( inv ) ;

    %%%%%%%%%%%%%%%%%%
    %Counterfactual (movers=0);
    %%%%%%%%%%%%%%%%%%

    %a) Skills;
    skills_children_T = data_counterfactual( data_counterfactual(:,fp.ind_data.child_age,h)==11 & data_counterfactual(:,fp.ind_data.moved,h)==0, fp.ind_data.child_C_tp1 , h ) ;
    data_skills_receivers_counter(1,h) =  nanmean( log(  skills_children_T ) );

    %b) Parenting Style;
    PS = data_counterfactual( data_counterfactual(:,fp.ind_data.child_age,h)<11 & data_counterfactual(:,fp.ind_data.moved,h)==0, fp.ind_data.ParStyle  , h ) ;
    data_PS_receivers_counter(1,h) =  nanmean( PS );

    %c) Parental Investments;
    inv = data_counterfactual( data_counterfactual(:,fp.ind_data.moved,h)==0, fp.ind_data.inv  , h ) ;
    data_inv_receivers_counter(1,h) =  nanmean( inv );

end



policy_effects.pe_level_skills_receiving_base = nanmean( data_skills_receivers_base ) ;
policy_effects.pe_level_skills_receiving_counter = nanmean( data_skills_receivers_counter) ;

policy_effects.pe_skills_moved     = nanmean( data_skills_movers_counter - data_skills_movers_base ) ;
policy_effects.pe_skills_receiving = nanmean( data_skills_receivers_counter - data_skills_receivers_base ) ;
policy_effects.pe_PS_moved         = nanmean( data_PS_movers_counter - data_PS_movers_base ) ;
policy_effects.pe_PS_receiving     = nanmean( data_PS_receivers_counter - data_PS_receivers_base ) ;
policy_effects.pe_inv_moved        = nanmean( data_inv_movers_counter - data_inv_movers_base ) ;
policy_effects.pe_inv_receiving    = nanmean( data_inv_receivers_counter - data_inv_receivers_base ) ;


  